cmake_minimum_required(VERSION 2.8)

project(libgo)

enable_language(C ASM)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DBOOST_USE_SEGMENTED_STACKS")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)

set(LFT_YUN_LIBS $ENV{LFT_YUN_LIBS})

set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS system filesystem thread REQUIRED)

include_directories(
	${PROJECT_SOURCE_DIR}/
	${PROJECT_SOURCE_DIR}/libgo
	${LFT_YUN_LIBS}/l-include
	${LFT_YUN_LIBS}/include
)

link_directories(
	${LIBRARY_OUTPUT_PATH}
	${LFT_YUN_LIBS}/libs/linux
)

file(GLOB
	LIBGO_FILES
	"libgo/cls/*.cpp"
	"libgo/common/*.cpp"
	"libgo/context/*.cpp"
	"libgo/context/*.S"
	"libgo/debug/*.cpp"
	"libgo/defer/*.cpp"
	"libgo/netio/unix/*.cpp"
	"libgo/pool/*.cpp"
	"libgo/scheduler/*.cpp"
	"libgo/sync/*.cpp"
	"libgo/task/*.cpp"
	"libgo/timer/*.cpp"
)
add_library(go ${LIBGO_FILES})

file(GLOB
	LIBGO_HOOK_FILES
	"libgo/netio/unix/static_hook/*.cpp"
)
add_library(gohk ${LIBGO_HOOK_FILES})

file(GLOB
	LIBGO_NHOOK_FILES
	"libgo/netio/disable_hook/*.cpp"
)
add_library(gonhk ${LIBGO_NHOOK_FILES})

add_subdirectory(test)
add_subdirectory(tutorial)